﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BoxScore.Objetos;

namespace BoxScore.Estadisticas
{
    public partial class _estDefensiva : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CheckBox1_CheckedChanged1(object sender, EventArgs e)
        {

            CheckBox check = sender as CheckBox;
            GridViewRow fila = (GridViewRow)check.NamingContainer;
            TextBox text = (TextBox)fila.FindControl("TextBox1");
            TextBox text2 = (TextBox)fila.FindControl("TextBox2");
            TextBox text3 = (TextBox)fila.FindControl("TextBox3");
            TextBox text4 = (TextBox)fila.FindControl("TextBox4");
            TextBox text5 = (TextBox)fila.FindControl("TextBox5");
            TextBox text6 = (TextBox)fila.FindControl("TextBox6");
            HiddenField hf = (HiddenField)fila.FindControl("hf");

            if (check.Checked)
            {
                text.Enabled = true;
                text2.Enabled = true;
                text3.Enabled = true;
                text4.Enabled = true;
                text5.Enabled = true;
                text6.Enabled = true;

            }
            else
            {
                text.Enabled = false;
                text2.Enabled = false;
                text3.Enabled = false;
                text4.Enabled = false;
                text5.Enabled = false;
                text6.Enabled = true;
            }

        }


        public List<EstadisticaDefensiva> getEstadisticasXPosicion()
        {
            List<EstadisticaDefensiva> _list = new List<EstadisticaDefensiva>();
            foreach (GridViewRow item in this.gvDefensivo.Rows)
            {
                CheckBox _check = (CheckBox) item.FindControl("CheckBox1");
                if (_check.Checked)
                {
                    EstadisticaDefensiva _ed = new EstadisticaDefensiva();
                    _ed.ip = double.Parse(((TextBox)item.FindControl("TextBox1")).Text);
                    _ed.outs = int.Parse(((TextBox)item.FindControl("TextBox2")).Text);
                    _ed.a = int.Parse(((TextBox)item.FindControl("TextBox3")).Text);
                    _ed.e = int.Parse(((TextBox)item.FindControl("TextBox4")).Text);
                    _ed.dp = int.Parse(((TextBox)item.FindControl("TextBox5")).Text);
                    _ed.pb = int.Parse(((TextBox)item.FindControl("TextBox6")).Text);
                    _ed.idposition = int.Parse(((HiddenField)item.FindControl("hf")).Value);
                    _list.Add(_ed);
                }
                
            }
            return _list;
        
        }
    }
}